/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package app.business;

import app.entity.Users;
import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author DangThanh
 */
@Stateless
@LocalBean
public class UserSessionBean {

    @PersistenceContext(unitName = "MailServerApplicationPU")
    private EntityManager em;

    public void persist(Object object) {
        em.persist(object);
    }

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    public List<Users> getAllUsers() {
        return em.createNamedQuery("Users.findAll").getResultList();
    }

    public Users addUser(Users user) {
        em.persist(user);
        return user;
    }
}
